package wordit.impl.boardwise;

import wordit.Dictionary;
import wordit.LetterSequence;
import wordit.ea.FitnessFunction;
import wordit.ea.Genome;

public class BoardwiseFitness implements FitnessFunction {
	
	private final Dictionary dictionary;

	public BoardwiseFitness(Dictionary dictionary) {
		this.dictionary = dictionary;
	}

	@Override
	public double eval(Genome gen) {
		BoardGenome board = (BoardGenome) gen;
		double fitness = 0;
		
		for (LetterSequence seq : board.getSequences()) {
			fitness += seq.getScore(dictionary);
		}
		
		return fitness;
	}

}
